import {action, Service} from "adajs";
import Input from "./../../../../controls/form/input";
import Text from "./../../../../controls/form/text";
import SikeSelect from "./../../../../controls/form/sikeselect";

class LodgeService extends Service {
    defaultData() {
        return {
            title: "设置",
            baseform: {
                fields: [
                    {type: SikeSelect, name: "ltzid", label: "姓名", required: true}
                ]
            },
            ltzid: "",
            ltzname: "",
            form: {
                fields: [
                    {type: Input, name: "zfsj", label: "看望时间", inputType: "date", required: true},
                    {type: Input, name: "zfdd", label: "看望地点", inputType: "text", required: true},
                    {type: Input, name: "zfld", label: "看望领导", inputType: "text", required: true},
                    {type: Text, name: "ptry", label: "陪同人员", inputType: "text", required: true},
                    {type: Text, name: "qtry", label: "其他人员", inputType: "text", required: true},
                    {type: Text, name: "wwp", label: "慰问品", inputType: "text", required: true},
                    {type: Text, name: "fywt", label: "反映问题", inputType: "text", required: true}
                ],
                btns: [
                    {action: "submit", name: "提交"}
                ]
            }
        };
    }

    onupdate(current, data) {
        Object.assign(current, data);
    }

    @action("setList")
    setList(current, data) {
        if (data && data.value) {
            current.ltzname = data.name;
            current.ltzid = data.value;
        } else {
            current.ltzname = "";
            current.ltzid = "";
        }
    }
}

export default LodgeService;